package Exercise108;

import java.util.Scanner;

public class Tets1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //查表法
        String[] Roma = {"","Ⅰ","Ⅱ","Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ"};
        System.out.println("请输入要转换的数字");
        String str = sc.next();
        while (Judge(str)) {
            System.out.println("输入长度非法或者有非法数据，请重新输入");
            str = sc.next();
        }
//        String result="";
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int res=c-48;
//            result+=Roma[res];
            sb.append(Roma[res]);
        }
        System.out.println(sb);

    }

    public static boolean Judge(String str) {
        if (str.length() > 9) {
            return true;
        }
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int res = c - 48;
            if (res > 9 || res < 0) {
                return true;
            }
        }
        return false;
    }
//一种新的思路就是包装一个函数 switch 对应令String str=（JDK12新特性）switch(){(或者里面用str="Ⅰ") }



}
